package com.healthcloud.config;

import com.healthcloud.utils.Constant;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author wangdi
 * @since 2024/9/4
 */
@Component
public class WechatMpConfig {

    @Bean
    public WxMpConfigStorage wxMpConfigStorage() {
        WxMpDefaultConfigImpl wxMpDefaultConfigImpl = new WxMpDefaultConfigImpl();
        wxMpDefaultConfigImpl.setAppId(Constant.WX_APPID);
        wxMpDefaultConfigImpl.setSecret(Constant.WX_SECRET);
        return wxMpDefaultConfigImpl;
    }
    @Bean
    public WxMpService wxMpService() {
        WxMpService wxMpService = new WxMpServiceImpl();
        wxMpService.setWxMpConfigStorage(wxMpConfigStorage());
        return wxMpService;
    }

}
